/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package medialibrary.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author user
 */
@Entity
@Table(name = "member")

public class Membre implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "memberId")
    private Integer memberId = 0;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "surname")
    private String surname;
    @Basic(optional = false)
    @NotNull
    @Column(name = "birthDate")
    @Temporal(TemporalType.DATE)
    private Date birthDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 7)
    @Column(name = "login")
    private String login;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 12)
    @Column(name = "password")
    private String password;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "registrationDate")
    @Temporal(TemporalType.DATE)
    private Date registrationDate;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "memberId")
    private Membercard membercard;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memberId")
    private Collection<Borrowing> borrowingCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memberId")
    private Collection<Reservation> reservationCollection;

    public Membre() {
    }

    public Membre(Integer memberId) {
        this.memberId = memberId;
    }

    public Membre(Integer memberId, String name, String surname, Date birthDate, String login, String password, String email, Date registrationDate) {
        this.memberId = memberId;
        this.name = name;
        this.surname = surname;
        this.birthDate = birthDate;
        this.login = login;
        this.password = password;
        this.email = email;
        this.registrationDate = registrationDate;
    }
    
     public Membre(String name, String surname, Date birthDate, String login, String password, String email, Date registrationDate) {
        
        this.name = name;
        this.surname = surname;
        this.birthDate = birthDate;
        this.login = login;
        this.password = password;
        this.email = email;
        this.registrationDate = registrationDate;
    }

    public Integer getMemberId() {
        return memberId;
    }

    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getRegistrationDate() {
        return registrationDate;
    }

    public void setRegistrationDate(Date registrationDate) {
        this.registrationDate = registrationDate;
    }

    public Membercard getMembercard() {
        return membercard;
    }

    public void setMembercard(Membercard membercard) {
        this.membercard = membercard;
    }

    public Collection<Borrowing> getBorrowingCollection() {
        return borrowingCollection;
    }

    public void setBorrowingCollection(Collection<Borrowing> borrowingCollection) {
        this.borrowingCollection = borrowingCollection;
    }

    public Collection<Reservation> getReservationCollection() {
        return reservationCollection;
    }

    public void setReservationCollection(Collection<Reservation> reservationCollection) {
        this.reservationCollection = reservationCollection;
    }

       public String toString() {
        return memberId + "";
    }
    
}
